package kr.ac.konkuk.dblab.point.metadata;

import java.awt.geom.Point2D;
import java.io.Serializable;

public class Rect implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -8405999024556691611L;
	
	public double left = 0, right = 0, top = 0, bottom = 0;
	
	public Rect() {
	}
	
	public Rect(double left, double top, double right, double bottom) {
		set(left, top, right, bottom);
	}
	
	public Rect(Point2D leftTop, Point2D rightBottom) {
		set(leftTop, rightBottom);
	}
	
	public void set(double left, double top, double right, double bottom) {
		this.left = left;
		this.top = top;
		this.right = right;
		this.bottom = bottom;
	}
	
	public void set(Point2D leftTop, Point2D rightBottom) {
		this.left = leftTop.getX();
		this.top = leftTop.getY();
		this.right = rightBottom.getX();
		this.bottom = rightBottom.getY();
	}
	
	public double width() {
		return Math.abs(right - left);
	}
	
	public double height() {
		return Math.abs(bottom - top);
	}
}
